<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@page import="iwpl.project.dao.FormsDAO"%>
<%@page import="iwpl.project.entities.Forms"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
//String t = (String)session.getAttribute("Manage_Forms");
//if(t!="active")
//	{response.sendRedirect("index.jsp");}
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'Manage_Forms.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

	</head>
	

 <script type="text/javascript">
			function Confirm(id) 
			{
				var text = confirm("Are you sure ?");
				
				if (text == true)
				{
					//alert("Okey, Deleted !!!");
					location.href = "./servlet/Control_Form?id="+id+"&action=Delete";
				}
				else 
				{
					alert("What ever !!!");
				}
			}
		</script>

	<body>
	<form name="frmManageForm" action="./servlet/Control_Form" method="get">
		<table align="left">
			<tr>
				<td colspan="5" align="center">
					<h1><br> 
						</h1><h1>Manage Forms 
					</h1>
				</td>
			</tr>
			<tr>
				<td colspan="4">
					<a href="Insert_Form.jsp">Insert</a>
				</td>
				
			</tr>
			<tr bgcolor="5f9ff5">
				<td>
					No
				</td>
				<td colspan="3">
					FormName
				</td>

			</tr>
			<%
											FormsDAO dao = new FormsDAO();
											List<Forms> list = dao.findAll();

											int i = 0;

											for (Iterator<Forms> it = list.iterator(); it.hasNext();) {
												Forms rol = (Forms) it.next();
												i++;

												if (i % 2 != 0) {
													out.println("<tr bgcolor=\"#CCFFFF\"><td>");
												} else {
													out.println("<tr bgcolor=\"#99CCCC\"><td>");
												}
												out.println(i + "</td>");
												out.println("<td>" + rol.getFormsName() + "</td>");
												

												//	out.println("<td>" + apart.getValue() + "</td>");
												//out.println("<td>" + rsq.getString("CountID") + "</td></tr>");
												//out.println("<td>" + rs.getString("Status") + "</td></tr>");
												out.println("<td><a href="
														+ "/DepartmentManage/Update_Form.jsp?fid="
														+ rol.getId().toString() + " /><img src="
														+ "./images/Edit.jpg" + " /></td>");
												/*out.println("<td><a href=" + "./servlet/myservlet?delete="
														+ rs.getString("CategoryID") + " /><img src="
														+ "./Pics/Delete.jpg" + " /></td></tr>");*/
												//out.println("<td><img src=\"./Pics/Delete.jpg\" onclick =\"Confirm()\"/></td></tr>");
												out.println("<td><a href=javascript:Confirm('" + rol.getId()
														+ "') /><img src=" + "./images/Delete.jpg"
														+ " /></td></tr>");
												

											}
										%>
		</table>
		</form>
	</body>
</html>
